package com.palrevo.utils;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;

/**
 * 
 * @author AAsha
 * 
 */
public abstract class FileUtilites {

	/**
	 * It copies all png and jpg images from directory to another.
	 * 
	 * @param fromDir
	 * @param toDir
	 * @throws IOException 
	 */
	public static void copyImages(String fromDir, String toDir) throws IOException {

		IOFileFilter pngSuffixFilter = FileFilterUtils.suffixFileFilter(".png");
		IOFileFilter jpgSuffixFilter = FileFilterUtils.suffixFileFilter(".jpg");

		FileFilter filter = FileFilterUtils
				.or(pngSuffixFilter, jpgSuffixFilter);

		try {
			FileUtils.copyDirectory(new File(fromDir), new File(toDir), filter);
		} catch (IOException e) {
			Log.error(FileUtilites.class, e.getMessage());
			throw e;
		}
	}

}
